package course13;

public class Worm implements IAnimal {

    private int lifeSate = 1;
    private int lifeValue;
    private int mySerial;

    @Override
    public int getState() {
        System.out.println("返回动物当前的状态");
        return 0;
    }

    @Override
    public void grow() {
        if (lifeSate == 1) {
            lifeValue = lifeValue + 1;
            if (lifeValue <= 5) {
                System.out.println("虫子" + mySerial + "现在" + lifeValue + "岁，是个孩子");
            } else if (lifeValue <= 15) {
                System.out.println("虫子" + mySerial + "现在" + lifeValue + "岁，是个青年");
            } else if (lifeValue <= 20) {
                System.out.println("虫子" + mySerial + "现在" + lifeValue + "岁，是个老人");
            } else if (lifeValue > 20) {
                System.out.println("虫子" + mySerial + "现在" + lifeValue + "岁，是个老年");
                lifeSate = -1;
            }
        }else{
            System.out.println("虫子" + mySerial + "已经死亡");
        }
    }

    public Worm() {
        mySerial = Serial.getSerial();
        System.out.println("我今天出生了，我是条虫子，我的编号是：" + mySerial);
    }
}
